home *** CD-ROM | disk | FTP | other *** search
- package LockemUp;
-
- import com.siemens.mp.game.GraphicObjectManager;
- import com.siemens.mp.game.Sprite;
-
- public class BaseActor {
- private GraphicObjectManager gfxManager;
- private int curAction;
- private int totalActions;
- private int frameCounter;
- private int frameRate;
- private int curFrame;
- private int[] framesCountList;
- private byte[][] animationPixels;
- private byte[][] maskPixels;
- private Sprite[] sprites;
- private int xPos;
- private int yPos;
- private int width;
- private int height;
- private boolean isVisible;
- private boolean isEndOfAction;
- private boolean isRewind;
- private boolean isPlaying;
-
- public BaseActor(GraphicObjectManager var1, int var2, int var3, int var4, boolean var5, boolean var6) {
- this.gfxManager = var1;
- this.totalActions = var2;
- this.width = var3;
- this.height = var4;
- this.isRewind = var5;
- this.isPlaying = var6;
- this.frameRate = 0;
- this.frameCounter = 0;
- this.curAction = -1;
- this.curFrame = 0;
- this.isVisible = false;
- this.framesCountList = new int[var2];
- this.animationPixels = new byte[var2][];
- this.maskPixels = new byte[var2][];
- this.sprites = new Sprite[var2];
- }
-
- public void Dispose() {
- this.gfxManager.deleteObject(this.sprites[this.curAction]);
-
- for(int var1 = 0; var1 < this.totalActions; ++var1) {
- this.animationPixels[var1] = null;
- this.maskPixels[var1] = null;
- }
-
- this.sprites = null;
- this.framesCountList = null;
- }
-
- public int appendAction(int var1, byte[] var2, byte[] var3, int var4) {
- if (var1 >= this.totalActions) {
- return 1;
- } else {
- this.animationPixels[var1] = var2;
- this.maskPixels[var1] = var3;
- this.framesCountList[var1] = var4;
- this.sprites[var1] = new Sprite(this.animationPixels[var1], 0, this.width, this.height, this.maskPixels[var1], 0, var4);
- this.gfxManager.addObject(this.sprites[var1]);
- return 0;
- }
- }
-
- public void setVisible(boolean var1) {
- this.isVisible = var1;
- this.sprites[this.curAction].setVisible(this.isVisible);
- }
-
- public void setActionCollisionBox(int var1, int var2, int var3, int var4, int var5) {
- this.sprites[var1].setCollisionRectangle(var2, var3, var4, var5);
- }
-
- public Sprite getCurSprite() {
- return this.sprites[this.curAction];
- }
-
- public boolean isCollidedWith(BaseActor var1) {
- return this.sprites[this.curAction].isCollidingWith(var1.getCurSprite());
- }
-
- public void setPosition(int var1, int var2) {
- this.xPos = var1;
- this.yPos = var2;
- }
-
- public void setPositionX(int var1) {
- this.xPos = var1;
- }
-
- public void setPositionY(int var1) {
- this.yPos = var1;
- }
-
- public int getPositionX() {
- return this.xPos;
- }
-
- public int getPositionY() {
- return this.yPos;
- }
-
- public int getWidth() {
- return this.width;
- }
-
- public int getHeight() {
- return this.height;
- }
-
- public int getCurrentFrame() {
- return this.curFrame;
- }
-
- public int getCurrentTotalFrames() {
- return this.framesCountList[this.curAction];
- }
-
- public int getCurrentAction() {
- return this.curAction;
- }
-
- public int getTotalActions() {
- return this.totalActions;
- }
-
- public void setFrameRate(int var1) {
- this.frameRate = var1;
- }
-
- public int changeToNewAction(int var1) {
- if (var1 >= this.totalActions) {
- return 1;
- } else {
- if (this.curAction >= 0) {
- this.setVisible(false);
- }
-
- this.curAction = var1;
- this.setVisible(true);
- this.isEndOfAction = false;
- this.curFrame = 0;
- this.sprites[this.curAction].setFrame(this.curFrame);
- return 0;
- }
- }
-
- public void setCurrentFrame(int var1) {
- if (var1 < this.framesCountList[this.curAction]) {
- this.curFrame = var1;
- this.sprites[this.curAction].setFrame(this.curFrame);
- }
- }
-
- public boolean isAnimationEnd() {
- return this.isEndOfAction;
- }
-
- public void frameActor() {
- if (this.isPlaying) {
- if (this.frameCounter == this.frameRate) {
- if (this.curFrame == this.framesCountList[this.curAction] - 1) {
- if (this.isRewind) {
- this.curFrame = 0;
- }
-
- this.isEndOfAction = true;
- } else {
- this.isEndOfAction = false;
- ++this.curFrame;
- }
-
- this.sprites[this.curAction].setFrame(this.curFrame);
- this.frameCounter = 0;
- } else {
- ++this.frameCounter;
- }
- }
-
- this.sprites[this.curAction].setPosition(this.xPos >> 8, this.yPos >> 8);
- }
- }
-